package org.wanda.pv.model.file;

import org.nutz.lang.Files;

import java.io.*;

public class PersistFile implements Serializable{
    private File file;

    private String orgFileName;

    public PersistFile(File file,String orgFileName){

        this.file = file;
        this.orgFileName = orgFileName;

    }
    public InputStream getInputStream() throws IOException {
        return new FileInputStream(this.file);
    }

    public String getOrgFileName(){
        return orgFileName;
    }


    public long getSize() {
        return this.file.length();
    }

    public void write(String fileName) throws IOException {
        Files.copy(this.file, new File(fileName));
    }

    public void delete() throws IOException {
        this.file.delete();
    }

    public File getFile() {
        return file;
    }

    public void setFile(File file) {
        this.file = file;
    }

}
